package com.bnyy.gbp;

import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.view.View;
import android.widget.TextView;

public class ViewUtils {

    public static final int LEFT = 0, TOP = 1, RIGHT = 2, BOTTOM = 3;

    public static void setTextViewDrawable(TextView textView, Drawable drawable, int location) {
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        switch (location) {
            case LEFT:
                textView.setCompoundDrawables(drawable, null, null, null);
                break;
            case TOP:textView.setCompoundDrawables(null, drawable, null, null);
                break;
            case RIGHT:textView.setCompoundDrawables(null, null, drawable, null);
                break;
            case BOTTOM:textView.setCompoundDrawables(null, null, null, drawable);
                break;
        }
    }

    public static void setCornerBgColor(View view, int Color) {
        GradientDrawable bg = new GradientDrawable();
        bg.setCornerRadius(ScreenHelper.dp2px(view.getContext(), 10));
        bg.setColor(Color);
        view.setBackground(bg);
    }
}
